<?php

class Application_Model_DbTable_NhomTaiKhoan extends Zend_Db_Table_Abstract
{

    protected $_name = 'NHOMTAIKHOAN';
    
    
    
    public function getDatas( $args = array() ){
        $select = $this->select();
        $select->from("NHOMTAIKHOAN",array("MaNhom","TenNhom"));
        
        $results = $this->fetchAll($select);
        $datas = $results->toArray();     
        return $datas;
    } 
    
    public function ajaxLoad( $datas = array() ){
        $table = new stdClass();
        $table->tbody = $this->getDatas();
        return $table;
    }
    
    public function ajaxInsert( $datas = array() ){
        $row = $this->createRow($datas);
        $row->save();
        $table = new stdClass();
        $table->tbody = $this->getDatas();
        return $table;
    }
    
    public function ajaxDelete( $datas = array() ){
        $row = $this->find($datas['MaNhom'])->current();
        $row->delete();
        $table = new stdClass();
        $table->tbody = $this->getDatas();
        return $table;
    }
    
    public function ajaxEdit( $datas = array() ){
        $row = $this->find($datas['MaNhom'])->current();
        $row->TenNhom = $datas['TenNhom'];
        $row->save();
        $table = new stdClass();
        $table->tbody = $this->getDatas();
        return $table;
    }
	
}

